/* Layout */
import Layout from '@/layout/Layout'  //如果使用懒加载的方式就没必要在这里进行引入了  component:() => import('../views/Login.vue')这个就是懒加载



/**
 * 登录
 */
export const loginRouter = [
  {
    path: '/login',
    name: 'login',
    meta: {title: '登录', isLogin: true },
    component: resolve => {
      require(['@/views/Login'], resolve)
    }
  }
]


/**
 * 主路由
 */
export const appRouter = [
  {
    path: '/',
    meta: {  title: '首页'},
    component: Layout,
    children:[
      {
        path: '/home',
        meta: {
          title: '首页',

        },
        name: 'home',
        component: resolve => {
          require(['@/views/Home'], resolve)
        }
      },
      {
        path: '/dashboard',
        meta: {
          title: '控制台',

        },
        name: 'dashboard',
        component: resolve => {
          require(['@/views/dashboard/Index'], resolve)
        }
      },
    ]
  },


  {
    path:"/sys",
    name:'sys',
    redirect: '/user',
    meta:{title:'系统管理'},
    component: Layout,
    children:[
      {
        path: '/user',
        name: 'user',
        meta: { title: '用户管理' },
        component: () => import("@/views/User"),

      },
      {
        path: '/role',
        name: 'role',
        meta: { title: '角色管理',  },
        component: () => import("@/views/Role"),
      },
      {
        path: '/menu',
        name: 'menu',
        meta: { title: '菜单管理',},
        component: () => import("@/views/Menu"),
      },
      {
        path: '/dept',
        name: 'dept',
        meta: { title: '部门管理',  keepAlive: true },
        component: () => import("@/views/Dept"),
      },
      {
        path: '/test',
        name: 'test',
        meta: { title: '测试页面',  keepAlive: true },
        component: () => import("@/views/Test"),
      },
      {
        path: '/500',
        name: '500',
        component: () => import("@/views/error/500"),
      },
    ]
  },

]


/**
 * 404
 */
export const pageError = {
  path: '*',
  name: '404',
  meta: {
    title: '404'
  },
  component: resolve => {
    require(['@/views/error/404'], resolve)
  }
}

/**
 * 401
 */
export const unauthorizedError = {
  path: '/401',
  name: '401',
  meta: { title: '401'},

  component: () => import('@/views/error/401')
  }


/**
 * 900 系统错误
 */
export const serveError = {
  path: '/900',
  name: '900',
  meta: {
    title: '900'
  },
  component: resolve => {
    require(['@/views/error/900'], resolve)
  }
}








export const routes = [ serveError, pageError, unauthorizedError, ...loginRouter, ...appRouter]
